<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 下拉框 -->
<link rel="stylesheet" href="<%=basePath%>statics/ace/css/chosen.css" />
<!-- jsp文件头和头部 -->
<%@ include file="../index/top.jsp"%>
</head>
<body class="no-skin">
	<!-- /section:basics/navbar.layout -->
	<div class="main-container" id="main-container">
		<!-- /section:basics/sidebar -->
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
								<form action="<%=basePath%>${baseInfo.moduleName!''}/${baseInfo.objectName!''}/${r"${action }"}" name="editForm" id="editForm" method="post">
									<input type="hidden" name="${baseInfo.primaryKeyProperty!''}" id="${baseInfo.primaryKeyProperty!''}" value="${r"${"}${baseInfo.objectName!''}.${baseInfo.primaryKeyProperty!''}${r"}"}"/>
									<div id="zhongxin" style="padding-top: 13px;">
									<table id="table_report" class="table table-striped table-bordered table-hover">
										<#list baseInfo.propertyInfos as pi>
										<tr>
											<td style="width:79px;text-align: right;padding-top: 13px;">${pi.remarks!''}:</td>
											<td><input  class="" type="text" name="${pi.propertyName!''}" id="${pi.propertyName!''}" value="${r"${"}${baseInfo.objectName!''}.${pi.propertyName!''}${r"}"}" maxlength="32" placeholder="这里输入${pi.remarks!''}" style="width:98%;" /></td>
										</tr>
										</#list>
										<#list baseInfo.listSelectPropertyInfo as pi>
											<td>${pi.remarks!''}:</td>
											<td style="vertical-align:top;padding-left:2px;">
											 	<select class="chosen-select form-control" name="${pi.propertyName!''}" id="${pi.propertyName!''}" placeholder="请选择${pi.remarks!''}" style="vertical-align:top;width: 120px;">
												<option value=""></option>
												<c:forEach items="${r"${listSmDict"}${pi.propertyName?cap_first}${r"}"}" var="dict">
													<option value="${r"${dict.dictCode }"}" <c:if test="${r"${"}${baseInfo.objectName!''}.${pi.propertyName!''}${r"==dict.dictCode}"}">selected</c:if>>${r"${dict.dictName }"}</option>
												</c:forEach>
											  	</select>
											</td>
										</#list>
										<tr>
											<td style="text-align: center;" colspan="10">
												<a class="btn btn-mini btn-primary" onclick="save();">保存</a>
												<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
											</td>
										</tr>
									</table>
									</div>
									<div id="zhongxin2" class="center" style="display:none"><br/><br/><br/><br/><img src="<%=basePath%>statics/images/jiazai.gif" /><br/><h4 class="lighter block green"></h4></div>
								</form>
						</div>
						<!-- /.col -->
					</div>
					<!-- /.row -->
				</div>
				<!-- /.page-content -->
			</div>
		</div>
		<!-- /.main-content -->
	</div>
	<!-- /.main-container -->
	<!-- basic scripts -->
	<!-- 页面底部js¨ -->
	<%@ include file="../index/foot.jsp"%>
	
	<script src="<%=basePath%>statics/ace/js/bootbox.js"></script>
	<!-- ace scripts -->
	<script src="<%=basePath%>statics/ace/js/ace/ace.js"></script>
	<!-- inline scripts related to this page -->
	<!-- 下拉框 -->
	<script src="<%=basePath%>statics/ace/js/chosen.jquery.js"></script>
	<!--提示框-->
	<script type="text/javascript" src="<%=basePath%>statics/js/jquery.tips.js"></script>
	
	<script type="text/javascript" src="<%=basePath%>statics/js/common/common.js"></script>
	
	<script type="text/javascript"
		src="<%=basePath%>statics/plugins/jqueryvalidation/jquery.validate.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>statics/plugins/jqueryvalidation/defined-validate-method.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>statics/plugins/jqueryvalidation/localization/messages_zh.js"></script>
</body>
<script type="text/javascript">
	$(top.hangge());
	var editFormValidate;
	$(document).ready(function(){
		if( ${r"$('#"}${baseInfo.primaryKeyProperty!''}').val()!=""){
			//编辑时哪些属性不可编辑 设置样式canotedit
			$(".canotedit").attr("readonly","readonly");
			$(".canotedit").css("color","gray");
		}
		//编辑时哪些属性验证需要修改
		editFormValidate = $("#editForm").validate({
			rules : {
				categoryName : {
					required : true,
					chinese : true
				},
				categoryCode : {
					required : true,
					number : true,
					fixlength : 3
				}
			},
			messages : {
				categoryName : {
					required : "请输入类目名称",
					chinese : "类目名称只能是中文"
				},
				categoryCode : {
					required : "请输入类目编码",
					number : "类目编码只能为数字"
				}
			}
		});
	});
	//保存
	function save(){
		var validateResult = editFormValidate.valid();
		if (!validateResult) {
			return false;
		}
	
		//属性值有效性验证
		var url = $('#editForm').attr('action');
		$.ajax({
			type : "POST",
			url : url,
			async : false,
			data : $('#editForm').serialize(),
			dataType : "json",
			success : function(data) {
				if(data){
					var errorCode = data.errorCode;
					if(errorCode == '0'){
						top.Dialog.close();
						return;
					}else{
						bootbox.alert(data.errorMsg);
					}
				}
			}
		});
	}
	
	$(function() {
		//下拉框
		if(!ace.vars['touch']) {
			$('.chosen-select').chosen({allow_single_deselect:true}); 
			$(window)
			.off('resize.chosen')
			.on('resize.chosen', function() {
				$('.chosen-select').each(function() {
					 var $this = $(this);
					 $this.next().css({'width': $this.parent().width()});
				});
			}).trigger('resize.chosen');
			$(document).on('settings.ace.chosen', function(e, event_name, event_val) {
				if(event_name != 'sidebar_collapsed') return;
				$('.chosen-select').each(function() {
					 var $this = $(this);
					 $this.next().css({'width': $this.parent().width()});
				});
			});
			$('#chosen-multiple-style .btn').on('click', function(e){
				var target = $(this).find('input[type=radio]');
				var which = parseInt(target.val());
				if(which == 2) $('#form-field-select-4').addClass('tag-input-style');
				 else $('#form-field-select-4').removeClass('tag-input-style');
			});
		}
	});
</script>
</html>